package com.company.web;

import com.company.api.UserServiceI;
import com.company.common.dto.R;
import com.company.dto.VisitorLoginCmd;
import com.company.dto.data.LoginInfoDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "游客相关接口")
@RequestMapping("/api/v1/visitors")
public class VisitorsController {
    private final UserServiceI userService;

    public VisitorsController(UserServiceI userService) {
        this.userService = userService;
    }

    @Operation(summary = "游客登录")
    @PostMapping("/sign-in")
    public R<LoginInfoDTO> login(@RequestBody VisitorLoginCmd cmd) {
        return R.data(userService.loginVisitor(cmd));
    }

    @Operation(summary = "测试")
    @PostMapping("/test")
    public R<Void> test() {
        return R.data(null);
    }

}
